<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>红包</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/store/css/newsj.css" />
		<link rel="stylesheet" href="__INDEX__/css/wallet.css" />
	</head>
	<style type="text/css">
		.mui-bar-nav {
			background: #FF4F40;
		}
		
		.hbitem_tip {
			padding: .5rem 0 .7rem;
		}
		
		.hb_pri {
			padding: 7px 0px 0px 0px;
		}
	</style>

	<body class="sjindexcon">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
			<h1 class="mui-title">发红包</h1>
		</header>
		<div class="mui-content sjindexcon">
			<div class="hongbbox">
				<div class="hongb_item clearfix">
					<div class="bt">单个金额</div>
					<div class="hb_srk glj"><input id="hbmoney" type="text" placeholder="0.00" onkeyup="key_up(this)"></div>
					<div class="tip">鼓励金</div>
				</div>
				<div class="hbitem_tip">鼓励金余额，
					<a href="hongb_pin.html">{$info_agent['score']}</a>
				</div>
				<div class="hongb_item clearfix" style="margin-top: 0;">
					<div class="bt">红包个数</div>
					<div class="hb_srk"><input id="hbnums" type="text" placeholder="填写个数" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')"></div>
					<div class="tip teb">个</div>
				</div>
				<div class="hbitem_tip">当前为普通红包，
					<a href="hongb_pin.html">改为拼手气红包</a>
				</div>
				<div class="hongb_item" style="margin-top: -1px;margin-bottom: 25px;">
					<div class="bt"><span>类型</span></div>
					<div class="hb_srk" style="padding-left: 150px">
						<select id="type">
							<option value="3">扫码红包</option>
							<option value="1">锁粉红包</option>
						</select>
					</div>
				</div>
				<div class="hb_tbtip"><textarea id="memo" placeholder="恭喜发财，大吉大利"></textarea></div>
				<div class="hb_pribox">
					<span class="iconfont "><img src="__PUBLIC__/static/wx/images/glj_tixian.png"></span>
					<span class="hb_pri">0.00</span>
				</div>
				<a href="#" class="hb_btn">塞钱进红包</a>
			</div>
		</div>
		<div class="mask" id='pay_by_score'>
			<div class="mask_con">
				<div class="top">
					<span class="del"><button type="button" onclick="$('.mask').hide()">X</button></span>
					<div style="text-align: center;">
						<span class="wz">请输入操作密码</span>
					</div>
					<span class="wz" style="width: 45%;"><a href="{:url('index/member/update_pwd2')}" style="float: right;font-size: 14px;color: red;margin-right: 15px;">忘记密码</a></span>
				</div>
				<div class="xfk_btn" id='is_pay_pwd' style="display: none;"><button type="button">设置支付密码</button></div>
				<div class="pwd-box" id='pay_pwd' style="none">
					<input type="tel" maxlength="6" class="pwd-input" id="pwd-input">
					<div class="fake-box">
						<input id="one" type="password" readonly="">
						<input type="password" readonly="">
						<input type="password" readonly="">
						<input type="password" readonly="">
						<input type="password" readonly="">
						<input type="password" readonly="">
					</div>
				</div>
			</div>
		</div>
		<script src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.all.js"></script>
		<script src="__PUBLIC__/static/js/help.js"></script>

		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script>
			function hidex() {
				$('#pay_by_score').hide();
				$(".fake-box input").val("");
				$('#qrfuk_btn').attr('disabled', false);
			}

			function key_up(obj) {
				clearNoNum1(obj);
				$(".hb_pri").text($(obj).val());
			}
			$(".hb_btn").click(function() {
				var hbmoney = $("#hbmoney").val();
				var hbnums = $("#hbnums").val();
				var my_score = parseFloat("{$info_agent['score']}");
				var o = $(this);
				if(hbmoney == "" || hbmoney == 0) {
					layer.msg('请输入红包金额');
					return;
				}
				if(hbnums == "" || hbnums == 0) {
					layer.msg('请输入红包个数');
					return;
				}
				if(hbmoney > 800) {
					layer.msg('个人红包不能超过800');
					return;
				}
				if(hbnums > 200) {
					layer.msg('红包个数不能超过200个');
					return;
				}
				if(hbmoney > my_score) {
					layer.msg('鼓励金账户余额不足');
					return;
				}
				$(this).attr({
					"disabled": "disabled"
				});
				$(".mask").show();
				$("#pwd-input").focus();
				$(".fake-box input").val();
			})
			var $input = $(".fake-box input");
			$("#pwd-input").on("input", function() {
				var pwd = $(this).val().trim();
				for(var i = 0, len = pwd.length; i < len; i++) {
					$input.eq("" + i + "").val(pwd[i]);
				}
				$input.each(function() {
					var index = $(this).index();
					if(index >= len) {
						$(this).val("");
					}
				});

				if(len == 6) {
					send_hb(pwd);
				}
			});

			function send_hb(pwd) {
				var hbmoney = $("#hbmoney").val();
				var hbnums = $("#hbnums").val();
				var type = $("#type").val();
				var index = layer.load(1, {
					shade: [0.1, '#fff']
				});
				$.ajax({
					url: "send_hb",
					data: {
						hbmoney: hbmoney,
						hbnums: hbnums,
						hbtype: 1,
						type: type,
						pwd: pwd,
						memo: $("#memo").val()
					},
					success: function(data) {
						layer.close(index);
						$(".mask").hide();
						$(".fake-box input").val("");
						if(data.code == 200) {
							window.location = "hongb02.html?m=" + data.id;
						} else {
							$("#pwd-input").val("");
							layer.msg(data.msg, {
								icon: 1,
								time: 1000
							}, function() {
								//location.reload();
							});
						}
					}
				})
			}
		</script>